
var vm = new Vue({
    el:"#ljw",
    data:{
        pageNum:1,
        pageSize:5,
        name:"",
        listSp:"",

        total:0,
        //总页数
        pages:0,
        isFirstPage:false,
        isLastPage:false,
        hasPreviousPage:false,
        hasNextPage:false,
        //所有导航页号
        navigatepageNums:[],

    },
    methods:{
        show(pageNum,pageSize){
            axios.get('/purchase/listSp',{
                params:{
                    pageNum:this.pageNum,
                    pageSize:this.pageSize,
                    name:this.name
                }
            }).then(res=>{
                vm.listSp=res.data.obj.list
                console.log(vm.listSp)
                this.pageNum=parseInt(res.data.obj.pageNum);
                this.pageSize=parseInt(res.data.obj.pageSize);
                this.total=parseInt(res.data.obj.total);
                this.pages=parseInt(res.data.obj.pages);
                this.isFirstPage=res.data.obj.isFirstPage;
                this.isLastPage=res.data.obj.isLastPage;
                this.hasPreviousPage=res.data.obj.hasPreviousPage;
                this.hasNextPage=res.data.obj.hasNextPage;
                this.navigatepageNums=res.data.obj.navigatepageNums;
            }).catch(err=>{

            })
        },
        //上一页
        qian(){
            if(this.hasPreviousPage==true){
                // alert("上一页")s
                //表示有上一页
                this.show(this.pageNum-1,this.pageSize);
            }
        },
        //下一页
        hou(){
            if(this.hasNextPage==true){
                this.show(this.pageNum+1,this.pageSize);
            }
        },
        bianji(id){
            localStorage.setItem("id",id)
            location.href="供应商编辑.html"
        },
        sc(id){
            axios.get('/purchase/deleSp',{
                params: {
                    id:id
                }
            },{

            }).then(res=>{
                alert("删除成功")
                location.reload();
            })
        }
    },
    mounted(){
        this.show(this.pageNum,this.pageSize)

    }
})